import React from 'react'

import {Consumer} from './context'
class Son extends Component{
    
    state={
        sonName:''
    }
    render(){
        const {sonName} = this.state
        return <Consumer>
               {
                   store =>{
                        return  <div className="son">
                        我的名字叫{store.name}
                        <input type="text" value={sonName} onChange={ev =>this.setState({sonName:ev.target.value})}/>
                        <button onClick={()=>store.setName(sonName)}>改名字</button>
                    </div>
                   }
               }
        </Consumer>
    }
}

export default Son